#pragma once

#include "Vector.h"
#include "Light.h"
#include "Ray.h"
#include "Color.h"
#include "RenderableObject.h"

class CCamera;

class CScene
{
public:
	std::map<std::string,CMaterial*> Materials;
	std::vector<CRenderableObject*> Objects;
	std::vector<CRenderableObject*> ReflectionCausticsEffectors;
	std::vector<CLight*> Lights;
	std::vector<CRenderableObject*> * m_Grid;
	void LoadObjects(std::string FileName,CCamera * camera);
	void LoadMaterials(std::string FileName);
	bool TestRay(const CRay &Ray);
	void RenderRay(CRay Ray, CColor&ResultColor);
	void RenderReflectionCaustics(const CRay &NormalRay, CColor&ResultColor);
	bool SeeLight(const CVector &ImpactPoint,const CLight *Light);
	double AO(const CRay &NormalRay,const CRenderableObject *Object); // Un Objet CRay contient une position et une direction (entre autres)
	void SetupScene(int FrameNumber);
	void BuildGrid();

	CRenderableObject * Scene_GetObject(const CRay &view);

	~CScene()
	{
		for(std::vector<CRenderableObject*>::iterator it = Objects.begin(); it != Objects.end(); ++it)
			delete(*it);
		for(std::vector<CLight*>::iterator it = Lights.begin(); it != Lights.end(); ++it)
			delete(*it);
	};
};
